//
//  ViewController.swift
//  BLE测试
//
//  Created by listen on 2018/1/24.
//  Copyright © 2018年 ls. All rights reserved.
//

import UIKit
import CoreBluetooth

class ViewController: UIViewController {
    var num : UInt8 = 0
    let mangerViewModel : BLEViewModel = BLEViewModel.shareInstane
    
    
    @IBAction func startScanPeripherals(_ sender: UIButton) {
        num += 2
       mangerViewModel.writeBleWithValue(num: num)
    }
    
    @IBAction func stopScanPeripheral(_ sender: UIButton) {
        
        num -= 2
        mangerViewModel.writeBleWithValue(num: num)
  
       
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        mangerViewModel.delegate = self
        
    }

    
}
extension ViewController:BLEViewModelDelegate{
    
    func BLEViewModelStatusHaveChange(status: CBCentralManagerState) {
        switch status {
        case .poweredOn:
            title = "BLE ON"
        case .poweredOff:
            title = "BLE OFF"
        default:
            title = "NOT KNOW"
        }
    }
    
}
